﻿<Window x:Class="DaxStudio.UI.Experiments.SpinnerTest"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
        xmlns:local="clr-namespace:DaxStudio.UI.Experiments"
        Title="SpinnerTest" Height="300" Width="300">
    <Window.Resources>
        <ResourceDictionary>
            <Style TargetType="FrameworkElement" x:Key="FadeInAnimation">
                <Setter Property="Visibility" Value="Collapsed"/>
                <Setter Property="Opacity" Value="0"/>
                <Style.Triggers>
                    <Trigger Property="Visibility" Value="Visible">
                        <Trigger.EnterActions>
                            <BeginStoryboard>
                                <Storyboard>
                                    <DoubleAnimation Storyboard.TargetProperty="Opacity"
                             From="0.0" To="1.0" Duration="0:0:0.2"/>
                                </Storyboard>
                            </BeginStoryboard>
                        </Trigger.EnterActions>
                    </Trigger>
                </Style.Triggers>
            </Style>


            <Style x:Key="BusyPanel" TargetType="Label">
                <Style.Setters>
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate>
                                <Border>
                                    <TextBlock>blah</TextBlock>
                                </Border>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>

                    <!--<Setter Property="Visibility" Value="Collapsed"/>-->
                    <Setter Property="Opacity" Value="70"/>
                </Style.Setters>

                <Style.Triggers>
                    <Trigger Property="Visibility" Value="Visible">
                        <Trigger.EnterActions>
                            <BeginStoryboard>
                                <Storyboard>
                                    <DoubleAnimation Storyboard.TargetProperty="Opacity"
                             From="0.0" To="1.0" Duration="0:0:0.2"/>
                                </Storyboard>
                            </BeginStoryboard>
                        </Trigger.EnterActions>
                    </Trigger>
                </Style.Triggers>
            </Style>


            <!-- Label Style -->
            <Style x:Key="LabelStyle1" TargetType="{x:Type Label}">
                <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
                <Setter Property="Background" Value="Transparent"/>
                <Setter Property="Padding" Value="5"/>
                <Setter Property="HorizontalContentAlignment" Value="Left"/>
                <Setter Property="VerticalContentAlignment" Value="Top"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type Label}">
                            <StackPanel Orientation="Horizontal">
                                <Ellipse Fill="{TemplateBinding Foreground}" Width="15" Height="15"></Ellipse>
                                <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="true">
                                    <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                                </Border>
                            </StackPanel>
                            <ControlTemplate.Triggers>
                                <Trigger Property="IsEnabled" Value="false">
                                    <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>



            <BooleanToVisibilityConverter x:Key="b2v" />
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary  Source="pack://application:,,,/DaxStudio.UI.Experiments;Component/ControlStyles.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>

    </Window.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <TextBlock Grid.Row="1">Hello World</TextBlock>
        <!--<Views:ucSpinner Grid.Row="1"  />-->
        <ToggleButton Name="Show" IsChecked="False" >Show me</ToggleButton>
        <Label Style="{StaticResource TextSpinnerStyle}" Grid.Row="1" Width="200" Height="100" Foreground="Green" Margin="0" Background="Blue">Hello world</Label>

        <!-- Busy overlay -->
        <!-- Visibility="{Binding IsBusy, Converter={StaticResource BoolToVisibilityConverter}}" -->
        <Label
            Grid.Row="1"
            BorderBrush="Black"
            Height="30"
            Margin="2"
            Padding="0"
            VerticalContentAlignment="Center"
            BorderThickness="1"
            FontWeight="Bold"
            FontFamily="Courier New"
            FontSize="24"
            Style="{StaticResource LabelSpinnerStyle}" >Running Query...</Label>
        <Border BorderBrush="Black" BorderThickness="1" 
                Background="#30000000" 
                Opacity="0.7"
                Visibility="{Binding IsChecked,ElementName=Show,Converter={StaticResource b2v}}"
                
                Grid.Row="1"
                Grid.RowSpan="1" 
                Style="{StaticResource FadeInAnimation}">
            <Grid>

                <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
                    <Label Style="{StaticResource SpinnerStyle}" Grid.Row="1" Width="20" Height="20" Foreground="Black" Opacity="0.5"/>
                    <TextBlock Margin="5,0,0,0" TextWrapping="Wrap" Text="Running Query..." HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="18" FontWeight="SemiBold" Foreground="Black" Opacity="0.5" />
                </StackPanel>
            </Grid>
        </Border>
    </Grid>
</Window>
